<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>grep (WordNet::Lexicon)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File lib/wordnet/lexicon.rb, line 258</span>
        <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">grep</span>( <span class="ruby-identifier">text</span> )
                <span class="ruby-keyword kw">return</span> [] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">text</span>.<span class="ruby-identifier">empty?</span>
                
                <span class="ruby-identifier">words</span> = []
                
                <span class="ruby-comment cmt"># Grab a cursor into the database and fetch while the key matches</span>
                <span class="ruby-comment cmt"># the target text</span>
                <span class="ruby-identifier">cursor</span> = <span class="ruby-ivar">@index_db</span>.<span class="ruby-identifier">cursor</span>
                <span class="ruby-identifier">rec</span> = <span class="ruby-identifier">cursor</span>.<span class="ruby-identifier">set_range</span>( <span class="ruby-identifier">text</span> )
                <span class="ruby-keyword kw">while</span> <span class="ruby-node">/^#{text}/</span> <span class="ruby-operator">=~</span> <span class="ruby-identifier">rec</span>[<span class="ruby-value">0</span>]
                        <span class="ruby-identifier">words</span>.<span class="ruby-identifier">push</span> <span class="ruby-identifier">rec</span>[<span class="ruby-value">0</span>]
                        <span class="ruby-identifier">rec</span> = <span class="ruby-identifier">cursor</span>.<span class="ruby-identifier">next</span>
                <span class="ruby-keyword kw">end</span>
                <span class="ruby-identifier">cursor</span>.<span class="ruby-identifier">close</span>

                <span class="ruby-keyword kw">return</span> <span class="ruby-operator">*</span><span class="ruby-identifier">words</span>
        <span class="ruby-keyword kw">end</span></pre>
</body>
</html>